package threading;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xwl
 * Date: 2023-08-10
 * Time: 23:09
 */
public class ThreadDemo21 {
    public static void main(String[] args) {
        // 此处并不是直接 new ExecutorService 对象
        // 而是通过 Executors 类里面的静态方法,完成对象的构造
        // 工厂模式(不再直接 new, 而是通过一些其他的方法协助创建对象)
        ExecutorService pool = Executors.newFixedThreadPool(10);
        // 添加任务到线程池
        pool.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello");
            }
        });
    }
}
